package com.sxran.im.handler;

import cn.hutool.core.util.ArrayUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sxran.im.bean.NotificationBody;
import com.sxran.im.dao.ImNotificationMapper;
import com.sxran.im.info.ImNotification;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

@Slf4j
@Service
public class ReadNotificationCmdHandler extends AbstractCmdHandler<ImNotification>{
    @Resource
    private ImNotificationMapper imNotificationMapper;

    @Override
    public Object doBeanService(ImNotification json) {
        // 删除对应的会话内容。
        LambdaQueryWrapper<ImNotification> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ImNotification::getUuid,json.getUuid());
        queryWrapper.eq(ImNotification::getToId,json.getToId());
        //
        ImNotification imFriendInvite = imNotificationMapper.selectOne(queryWrapper);
        if (imFriendInvite != null) {
            imFriendInvite.setIsRead(1);
            imNotificationMapper.update(imFriendInvite,queryWrapper);
        }
        return json;
    }



}
